<?php
namespace app\controller\v0;

use think\facade\View;

use app\model\Industry as IndustryModel;

class Industry  extends Base
{
    public function index() 
    {
        $list = IndustryModel::field('id, title, titlepic, summary, create_time')->order('id', 'desc')->paginate(12);

        return View::fetch('', ['list'=>$list]);
    }

    public function read($id = 0)
    {
        if ($id == 0) {
            return $this->notFound("文章不存在");
        }

        $data = IndustryModel::getOne($id);

        $nextprev = IndustryModel::getNextPrev($id);
        
        if ($data->type==1) {
            view::engine()->layout(false);
            $content = View::display($data->content);
            
            view::engine()->layout(true);
            
            return View::fetch('readhtml', [
                'content'  => $content,
                'nextprev' => $nextprev
            ]);
        } else {
            view::engine()->layout(true);

            return View::fetch('', [
                'data'     => $data,
                'nextprev' => $nextprev
            ]);
        }
    }
}